import struct

# 1字节类型
char_b = struct.pack('b',1)
char_B = struct.pack('B',2)
print("char 'b' size:",len(char_b),char_b)
print("char 'B' size:",len(char_B),char_B)

# 2字节类型
short_h = struct.pack('h',1)
short_H = struct.pack('H',2)
print("short_h 'h' size:",len(short_h),short_h)
print("short_H 'H' size:",len(short_H),short_H)

# 4字节类型
int_i = struct.pack('i',1)
int_I = struct.pack('I',1)
print("int 'b' size:",len(int_i),int_i)
print("uint 'B' size:",len(int_I),int_I)


# float 4字节类型
float_f = struct.pack('f',1.0)
print("float_f 'f' size:",len(float_f),float_f)

# double 8字节类型
float_d = struct.pack('d',1.0)
print("float_d 'd' size:",len(float_d),float_d)